
<script setup lang="ts">
/*
 * @description:用户表 
 * @author: lxx
 * @date: 2025-8-17
 * @version: V1.0.0
 */
import { dataSaveApi } from '@/api/system/user'
import type { ItemFormInt } from '@/api/system/user/types'
import { useAddEdit } from '@/hooks/system/useFramework'
import constants from '@/common/constant'
const dataFormRef = ref()
const formData = ref<ItemFormInt>({
  /** ID */
  id: -1,
  
  /** 用户名 */
  username: '',
  
  /** 昵称 */
  nickname: '',
  
  /** 性别;1-男 2-女 0-保密 */
  gender: 1,
  
  /** 联系方式 */
  phone: '',
  
  /** 状态;1-正常 0-禁用 */
  status: 1,
})
const { isEdit, loading, dialog, open, handleSubmitClick, handleCloseDialog } = useAddEdit<ItemFormInt>(dataSaveApi, formData, dataFormRef)
const rules = {
  /** ID */
  id: [{ required: true, message: '请输入ID', trigger: 'blur' }],
  /** 用户名 */
  username: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
  /** 昵称 */
  nickname: [{ required: true, message: '请输入昵称', trigger: 'blur' }],
  /** 性别;1-男 2-女 0-保密 */
  gender: [{ required: true, message: '请输入性别', trigger: 'blur' }],
  /** 密码 */
  // password: [{ required: true, message: '请输入密码', trigger: 'blur' }],
  /** 用户头像 */
  // avatar: [{ required: true, message: '请输入用户头像', trigger: 'blur' }],
  /** 联系方式 */
  phone: [{ required: true, message: '请输入联系方式', trigger: 'blur' }],
  /** 状态;1-正常 0-禁用 */
  status: [{ required: true, message: '请输入状态', trigger: 'blur' }],
}
defineExpose({
  open
})
</script>
<template>
  <!--字典弹窗-->
  <el-dialog v-loading="loading" v-model="dialog.visible" :title="dialog.title" width="500px" @close="handleCloseDialog">
    <el-form ref="dataFormRef" :model="formData" :rules="rules" label-width="80px">
      
      
      <el-form-item label="用户名" prop="username">
        <el-input v-model="formData.username" placeholder="请输入用户名" />
      </el-form-item>
      
      <el-form-item label="昵称" prop="nickname">
        <el-input v-model="formData.nickname" placeholder="请输入昵称" />
      </el-form-item>
      
      <el-form-item label="性别" prop="gender">
        <!-- <el-input v-model="formData.gender" placeholder="请输入性别" /> -->
        <Dict :code="constants.SEX" v-model="formData.gender" type="radio" />
      </el-form-item>
      
      <!-- <el-form-item label="密码" prop="password" v-if="!isEdit">
        <el-input v-model="formData.password" placeholder="请输入密码" />
      </el-form-item> -->
      
      <!-- <el-form-item label="用户头像" prop="avatar">
        <el-input v-model="formData.avatar" placeholder="请输入用户头像" />
      </el-form-item> -->
      
      <el-form-item label="联系方式" prop="phone">
        <el-input v-model="formData.phone" placeholder="请输入联系方式" />
      </el-form-item>
      
      <el-form-item label="状态" prop="status">
        <!-- <el-input v-model="formData.status" placeholder="请输入状态" /> -->
        <Dict :code="constants.STATUS" v-model="formData.status" type="radio" />

      </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button type="primary" @click="handleSubmitClick()">确 定</el-button>
        <el-button @click="handleCloseDialog()">取 消</el-button>
      </div>
    </template>
  </el-dialog>
</template>
<style lang="scss" scoped></style>